//
//  VIPMallIndexHeadView.swift
//  LeGou
//
//  Created by 刘亿前 on 2022/10/20.
//

import UIKit

class VIPMallIndexHeadView: UIView {
    // 头像
    @IBOutlet weak var userImg: UIButton!
    // 昵称
    @IBOutlet weak var userName: UILabel!
    // 查看余额
    @IBOutlet weak var detailBtn: UIButton!
    // 服务标识
    @IBOutlet weak var serverIcon: UIImageView!
    // 余额
    @IBOutlet weak var balanceView: UIView!
    @IBOutlet weak var balance: UILabel!
    // 冻结中
    @IBOutlet weak var frozenView: UIView!
    @IBOutlet weak var frozen: UILabel!
    
    @IBOutlet weak var djz: UILabel!
    
    // 积分
    @IBOutlet weak var integralView: UIView!
    @IBOutlet weak var integral: UILabel!
    // 活跃度
    @IBOutlet weak var activityView: UIView!
    @IBOutlet weak var activity: UILabel!
    
    let disposeBag = DisposeBag()
    
    override func awakeFromNib() {
        super.awakeFromNib()
        bindAction()
        if AppHelper.appVerify() {
            djz.text = "未结算"
        } else {
            djz.text = "冻结中"
        }
    }

    // MARK: - bindAction
    func bindAction() {
        detailBtn.rx.tap.subscribe(onNext:{ resp in
            if !LoginService.shared.checkLogin() {return}
            router.push("xm://main/VIPMall/wallet/index")
        }).disposed(by: disposeBag)
        
        let balanceTap = UITapGestureRecognizer()
        balanceView.addGestureRecognizer(balanceTap)
        balanceTap.rx.event.subscribe(onNext: { recognizer in
            if !LoginService.shared.checkLogin() {return}
            router.push("xm://main/VIPMall/wallet/index")
        }).disposed(by: disposeBag)
        
        let integralTap = UITapGestureRecognizer()
        integralView.addGestureRecognizer(integralTap)
        integralTap.rx.event.subscribe(onNext: { recognizer in
            if !LoginService.shared.checkLogin() {return}
            UIApplication.zm.visibleNavigationController().pushViewController(IntegralDetailVC(), animated: true)
        }).disposed(by: disposeBag)
        
        let activityTap = UITapGestureRecognizer()
        activityView.addGestureRecognizer(activityTap)
        activityTap.rx.event.subscribe(onNext: { recognizer in
            if !LoginService.shared.checkLogin() {return}
            UIApplication.zm.visibleNavigationController().pushViewController(ActivityNum(), animated: true)
        }).disposed(by: disposeBag)
    }

}
